/*
 * Copyright 2008-2012 Centro Andaluz de Innovación y Tecnologías de la
 * Información y las Comunicaciones (CITIC). All Rights Reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
 *
 * Please contact CITIC - Edificio CITIC, C/ Marie Curie, 6 Parque
 * Tecnológico de Andalucía 29590 - Campanillas, Málaga, Spain
 * or visit www.citic.es, if you need additional information or
 * have any questions.
 */

package es.citic.puedes.youtube.test.unit;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;

import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import es.citic.puedes.youtube.IYouTubeManager;
import es.citic.puedes.youtube.YouTubeAuthException;
import es.citic.puedes.youtube.YouTubeException;
import es.citic.puedes.youtube.bbdd.YouTubeDataBase;
import es.citic.puedes.youtube.impl.YouTubeManagerImpl;
import es.citic.puedes.youtube.model.Category;
import es.citic.puedes.youtube.model.UserPreferences;
import es.citic.puedes.youtube.model.YouTubePlayList;
import es.citic.puedes.youtube.model.YouTubePlayListEntry;
import es.citic.puedes.youtube.model.YouTubeUser;
import es.citic.puedes.youtube.model.YouTubeVideo;
import es.citic.puedes.youtube.model.YouTubeVideo.State;
import es.citic.puedes.youtube.model.YouTubeVideoMinimal;

public class PU_YouTubeManager_2 {

	private YouTubeDataBase dataBase;
	private IYouTubeManager youtube;

	@Before
	public void setUp() throws Throwable {
		// HSQLDB in memory config
		Map<String, String> properties = new HashMap<String, String>();
		properties.put(PersistenceUnitProperties.JDBC_DRIVER,
				"org.hsqldb.jdbcDriver");
		properties.put(PersistenceUnitProperties.JDBC_URL,
				"jdbc:hsqldb:mem:test");
		properties.put(PersistenceUnitProperties.JDBC_USER, "SA");
		properties.put(PersistenceUnitProperties.JDBC_PASSWORD, "");
		properties.put(PersistenceUnitProperties.DDL_GENERATION,
				"drop-and-create-tables");
		// properties.put("eclipselink.logging.level", "FINE");

		dataBase = new YouTubeDataBase("YouTubeManager_pu", properties);
		youtube = new YouTubeManagerImpl("META-INF/config.xml", dataBase);
	}

	@After
	public void tearDown() throws Exception {
		dataBase.cleanEntityManager();
	}

	@Test
	public void test_PU_65() throws SecurityException, YouTubeException {
		/*
		 * addPlayList(YouTubeUser, String, String)
		 */
		try {
			String titulo = "titulo";
			String descripcion = "descripcion";
			youtube.addPlayList(null, titulo, descripcion);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_66() throws SecurityException, YouTubeException {
		/*
		 * addPlayList(YouTubeUser, String, String)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			String descripcion = "descripcion";
			youtube.addPlayList(user, null, descripcion);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_67() throws SecurityException, YouTubeException {
		/*
		 * addPlayList(YouTubeUser, String, String)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			String descripcion = "descripcion";
			youtube.addPlayList(user, "", descripcion);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_68() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * addPlayList(YouTubeUser, String, String)
		 */
		int userId = 1;
		String youtubeName = "you2bectc";
		String youtubePass = "citiccitic";
		youtube.registreUser(userId, youtubeName, youtubePass);

		// getting user profile
		YouTubeUser user = youtube.getUserProfile(userId);

		Random rnd = new Random(); 
		int index = rnd.nextInt(100) ; 
		
		String titulo = index + "_mi_titulo";
		String descripcion = index + "mi_descripcion";
		youtube.addPlayList(user, titulo, descripcion);
	}

	@Test
	public void test_PU_69() throws SecurityException, YouTubeException {
		/*
		 * getPlayLists(YouTubeUser user)
		 */
		try {
			youtube.getPlayLists(null);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_70() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * getPlayLists(YouTubeUser user)
		 */
		int userId = 1;
		String youtubeName = "you2bectc";
		String youtubePass = "citiccitic";
		youtube.registreUser(userId, youtubeName, youtubePass);

		// getting user profile
		YouTubeUser user = youtube.getUserProfile(userId);

		List<YouTubePlayList> lists = youtube.getPlayLists(user);
		assertNotNull(lists);
		assertTrue(lists.size() > 0);
	}

	@Test
	public void test_PU_71() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * addVideoPlayList(YouTubeUser user, String videoID, String playListID)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			String videoID = "17_SS4T-z6A";
			String playListID = youtube.getPlayLists(user).get(0)
					.getPlaylistId();

			youtube.addVideoPlayList(null, videoID, playListID);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_72() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * addVideoPlayList(YouTubeUser user, String videoID, String playListID)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			String playListID = youtube.getPlayLists(user).get(0)
					.getPlaylistId();

			youtube.addVideoPlayList(user, null, playListID);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_73() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * addVideoPlayList(YouTubeUser user, String videoID, String playListID)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			String videoID = "17_SS4T-z6A";

			youtube.addVideoPlayList(user, videoID, null);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_74() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * addVideoPlayList(YouTubeUser user, String videoID, String playListID)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			String playListID = youtube.getPlayLists(user).get(0)
					.getPlaylistId();

			youtube.addVideoPlayList(user, "", playListID);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_75() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * addVideoPlayList(YouTubeUser user, String videoID, String playListID)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			String videoID = "17_SS4T-z6A";

			youtube.addVideoPlayList(user, videoID, "");
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_76() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * addVideoPlayList(YouTubeUser user, String videoID, String playListID)
		 */
		int userId = 1;
		String youtubeName = "you2bectc";
		String youtubePass = "citiccitic";
		youtube.registreUser(userId, youtubeName, youtubePass);

		// getting user profile
		YouTubeUser user = youtube.getUserProfile(userId);

		String videoID = "17_SS4T-z6A";
		YouTubeVideo video = youtube.getVideo(videoID);
		
		String playListID = youtube.getPlayLists(user).get(0).getPlaylistId();
		
		youtube.addVideoPlayList(user, videoID, playListID);
		List<YouTubePlayListEntry> list = youtube.getPlayList(playListID);
		assertTrue(list.size() > 0);

		boolean found = false;
		for (int i = 0; i < list.size(); i++) {
			YouTubePlayListEntry entry = list.get(i);			
			if (entry.getTitle().equals(video.getTitle())) {
				found = true;
			}
		}
		assertTrue(found);
	}

	@Test
	public void test_PU_77() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * getPlayList(String urlPlayList)
		 */
		try {
			youtube.getPlayList(null);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_78() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * getPlayList(String urlPlayList)
		 */
		try {
			youtube.getPlayList("");
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_79() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * getPlayList(String playListID)
		 */
		String playListID = "0F075E45C1E75914";
		List<YouTubePlayListEntry> list = youtube.getPlayList(playListID);
		assertNotNull(list);
		assertTrue(list.size() > 0);
	}

	@Test
	public void test_PU_80() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * deleteVideoPlayList(YouTubeUser user, String videoID, String
		 * playListID)
		 */
		try {
			String videoID = "17_SS4T-z6A";
			String playListID = "20F8586E4A569849";
			youtube.deleteVideoPlayList(null, videoID, playListID);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_81() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * deleteVideoPlayList(YouTubeUser user, String videoID, String
		 * playListID)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			String playListID = "20F8586E4A569849";
			youtube.deleteVideoPlayList(user, null, playListID);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_82() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * deleteVideoPlayList(YouTubeUser user, String videoID, String
		 * playListID)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			String videoID = "17_SS4T-z6A";
			youtube.deleteVideoPlayList(user, videoID, null);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_83() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * deleteVideoPlayList(YouTubeUser user, String videoID, String
		 * playListID)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			String playListID = "20F8586E4A569849";
			youtube.deleteVideoPlayList(user, "", playListID);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_84() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * deleteVideoPlayList(YouTubeUser user, String videoID, String
		 * playListID)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			String videoID = "17_SS4T-z6A";
			youtube.deleteVideoPlayList(user, videoID, "");
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_85() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * deleteVideoPlayList(YouTubeUser user, String videoID, String
		 * playListID)
		 */
		int userId = 1;
		String youtubeName = "you2bectc";
		String youtubePass = "citiccitic";
		youtube.registreUser(userId, youtubeName, youtubePass);

		// getting user profile
		YouTubeUser user = youtube.getUserProfile(userId);

		String videoID = "17_SS4T-z6A";
		YouTubeVideo video = youtube.getVideo(videoID);
		
		String playListID = youtube.getPlayLists(user).get(0).getPlaylistId();
		
		youtube.addVideoPlayList(user, videoID, playListID);
		List<YouTubePlayListEntry> list = youtube.getPlayList(playListID);
		assertTrue(list.size() > 0);

		boolean found = false;
		String playListVideoID = "";
		for (int i = 0; i < list.size(); i++) {
			YouTubePlayListEntry entry = list.get(i);			
			if (entry.getTitle().equals(video.getTitle())) {
				playListVideoID = entry.getVideoId();
				found = true;
			}
		}
		assertTrue(found);
		 
		youtube.deleteVideoPlayList(user, playListVideoID, playListID);
		list = youtube.getPlayList(playListID);

		boolean notfound = true;
		for (int i = 0; i < list.size(); i++) {
			YouTubePlayListEntry entry = list.get(i);
			if (entry.getVideoId().equals(videoID)) {
				notfound = false;
			}
		}
		assertTrue(notfound);
	}

	@Test
	public void test_PU_86() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * deletePlayList(YouTubeUser user, String playListID)
		 */
		try {
			String playListID = "20F8586E4A569849";
			youtube.deletePlayList(null, playListID);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_87() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * deletePlayList(YouTubeUser user, String playListID)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			youtube.deletePlayList(user, null);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_88() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * deletePlayList(YouTubeUser user, String playListID)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			youtube.deletePlayList(user, "");
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_89() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * deletePlayList(YouTubeUser user, String playListID)
		 */
		int userId = 1;
		String youtubeName = "you2bectc";
		String youtubePass = "citiccitic";
		youtube.registreUser(userId, youtubeName, youtubePass);

		// getting user profile
		YouTubeUser user = youtube.getUserProfile(userId);

		String playListID = youtube.getPlayLists(user).get(0).getPlaylistId();				
		youtube.deletePlayList(user, playListID);

		List<YouTubePlayList> list = youtube.getPlayLists(user);
		boolean notfound = true;
		for (int i = 0; i < list.size(); i++) {
			YouTubePlayList entry = list.get(i);
			if (entry.getPlaylistId().equals(playListID)) {
				notfound = false;
			}
		}
		assertTrue(notfound);
	}

	@Test
	public void test_PU_90() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * addComment(YouTubeUser user, String videoID, String comment)
		 */
		try {
			String videoID = "17_SS4T-z6A";
			String comment = "Comentario";
			youtube.addComment(null, videoID, comment);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_91() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * addComment(YouTubeUser user, String videoID, String comment)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			String comment = "Comentario";
			youtube.addComment(user, null, comment);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_92() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * addComment(YouTubeUser user, String videoID, String comment)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			String comment = "Comentario";
			youtube.addComment(user, "", comment);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_93() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * addComment(YouTubeUser user, String videoID, String comment)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			String videoID = "17_SS4T-z6A";
			youtube.addComment(user, videoID, null);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_94() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * addComment(YouTubeUser user, String videoID, String comment)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			String videoID = "17_SS4T-z6A";
			youtube.addComment(user, videoID, "");
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_95() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * addComment(YouTubeUser user, String videoID, String comment)
		 */
		int userId = 1;
		String youtubeName = "you2bectc";
		String youtubePass = "citiccitic";
		youtube.registreUser(userId, youtubeName, youtubePass);

		// getting user profile
		YouTubeUser user = youtube.getUserProfile(userId);

		String videoID = "17_SS4T-z6A";
		String comment = "Comentario";
		youtube.addComment(user, videoID, comment);
	}

	@Test
	public void test_PU_96() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * addRating(YouTubeUser user, String videoID, Integer value)
		 */
		try {
			String videoID = "17_SS4T-z6A";
			int value = 3;
			youtube.addRating(null, videoID, value);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_97() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * addRating(YouTubeUser user, String videoID, Integer value)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			int value = 3;
			youtube.addRating(user, null, value);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_98() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * addRating(YouTubeUser user, String videoID, Integer value)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			String videoID = "17_SS4T-z6A";
			youtube.addRating(user, videoID, null);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_99() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * addRating(YouTubeUser user, String videoID, Integer value)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			int value = 3;
			youtube.addRating(user, "", value);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_100() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * addRating(YouTubeUser user, String videoID, Integer value)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			int value = -1;
			String videoID = "17_SS4T-z6A";
			youtube.addRating(user, videoID, value);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_101() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * addRating(YouTubeUser user, String videoID, Integer value)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			int value = 10;
			String videoID = "17_SS4T-z6A";
			youtube.addRating(user, videoID, value);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_102() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * addRating(YouTubeUser user, String videoID, Integer value)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			YouTubeVideo videoToUpload = new YouTubeVideo();

			List<String> keyWordsTestList = new ArrayList<String>();
			keyWordsTestList.add("tortuga");
			keyWordsTestList.add("mascota");
			keyWordsTestList.add("animal");

			List<Category> categories = new ArrayList<Category>();
			categories.add(Category.ANIMALS);

			videoToUpload.setKeyWords(keyWordsTestList);
			videoToUpload.setCategories(categories);
			videoToUpload.setPublicationState(State.PUBLIC);
			videoToUpload.setTitle("test video title");
			videoToUpload.setDescription("test video description ");

			String videoPath = "C:\\Cristina\\freezing-fart.avi";

			youtube.insertVideo(user, videoToUpload, videoPath);

			YouTubeVideoMinimal video = youtube.getUserVideos(user).get(0);

			int value = 3;
			String videoID = video.getVideoId();
			youtube.addRating(user, videoID, value);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_103() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * addRating(YouTubeUser user, String videoID, Integer value)
		 */
		int userId = 1;
		String youtubeName = "you2bectc";
		String youtubePass = "citiccitic";
		youtube.registreUser(userId, youtubeName, youtubePass);

		// getting user profile
		YouTubeUser user = youtube.getUserProfile(userId);

		int value = 3;
		String videoID = "y8w1fHfcqqE";
		youtube.addRating(user, videoID, value);
	}

	@Test
	public void test_PU_104() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * updateVideo(YouTubeUser user, String youtubeVideoId, String title,
		 * String description, List<String> keyWords)
		 */
		try {
			String videoID = "17_SS4T-z6A";
			String title = "Nuevo titulo";
			String description = "Nueva descripcion";

			List<String> keywords = new ArrayList<String>();
			keywords.add("animalitos");

			youtube.updateVideo(null, videoID, title, description, keywords);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_105() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * updateVideo(YouTubeUser user, String youtubeVideoId, String title,
		 * String description, List<String> keyWords)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			String title = "Nuevo titulo";
			String description = "Nueva descripcion";

			List<String> keywords = new ArrayList<String>();
			keywords.add("animalitos");

			youtube.updateVideo(user, null, title, description, keywords);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_106() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * updateVideo(YouTubeUser user, String youtubeVideoId, String title,
		 * String description, List<String> keyWords)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			String videoID = "17_SS4T-z6A";
			String description = "Nueva descripcion";

			List<String> keywords = new ArrayList<String>();
			keywords.add("animalitos");

			youtube.updateVideo(user, videoID, null, description, keywords);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_107() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * updateVideo(YouTubeUser user, String youtubeVideoId, String title,
		 * String description, List<String> keyWords)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			String videoID = "17_SS4T-z6A";
			String title = "Nuevo titulo";

			List<String> keywords = new ArrayList<String>();
			keywords.add("animalitos");

			youtube.updateVideo(user, videoID, title, null, keywords);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_108() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * updateVideo(YouTubeUser user, String youtubeVideoId, String title,
		 * String description, List<String> keyWords)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			String videoID = "17_SS4T-z6A";
			String title = "Nuevo titulo";
			String description = "Nueva descripcion";

			youtube.updateVideo(user, videoID, title, description, null);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_109() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * updateVideo(YouTubeUser user, String youtubeVideoId, String title,
		 * String description, List<String> keyWords)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			String title = "Nuevo titulo";
			String description = "Nueva descripcion";

			List<String> keywords = new ArrayList<String>();
			keywords.add("animalitos");

			youtube.updateVideo(user, "", title, description, keywords);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_110() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * updateVideo(YouTubeUser user, String youtubeVideoId, String title,
		 * String description, List<String> keyWords)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			String videoID = "17_SS4T-z6A";
			String title = "Nuevo titulo";
			String description = "Nueva descripcion";

			List<String> keywords = new ArrayList<String>();

			youtube.updateVideo(user, videoID, title, description, keywords);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_111() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * updateVideo(YouTubeUser user, String youtubeVideoId, String title,
		 * String description, List<String> keyWords)
		 */
		int userId = 1;
		String youtubeName = "you2bectc";
		String youtubePass = "citiccitic";
		youtube.registreUser(userId, youtubeName, youtubePass);

		// getting user profile
		YouTubeUser user = youtube.getUserProfile(userId);

		YouTubeVideo videoToUpload = new YouTubeVideo();

		List<String> keyWordsTestList = new ArrayList<String>();
		keyWordsTestList.add("tortuga");
		keyWordsTestList.add("mascota");
		keyWordsTestList.add("animal");

		List<Category> categories = new ArrayList<Category>();
		categories.add(Category.ANIMALS);

		videoToUpload.setKeyWords(keyWordsTestList);
		videoToUpload.setCategories(categories);
		videoToUpload.setPublicationState(State.PUBLIC);
		videoToUpload.setTitle("test video title");
		videoToUpload.setDescription("test video description ");

		String videoPath = "C:\\Cristina\\freezing-fart.avi";

		youtube.insertVideo(user, videoToUpload, videoPath);

		YouTubeVideoMinimal video = youtube.getUserVideos(user).get(0);

		String videoID = video.getVideoId();
		String title = "Nuevo titulo";
		String description = "Nueva descripcion";

		List<String> keywords = new ArrayList<String>();
		keywords.add("squirrel");

		youtube.updateVideo(user, videoID, title, description, keywords);
	}

	@Test
	public void test_PU_112() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * addFavorites(YouTubeUser user, String videoID)
		 */
		try {
			String videoID = "17_SS4T-z6A";
			youtube.addFavorites(null, videoID);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_113() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * addFavorites(YouTubeUser user, String videoID)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			youtube.addFavorites(user, null);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_114() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * addFavorites(YouTubeUser user, String videoID)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			youtube.addFavorites(user, "");
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_115() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * addFavorites(YouTubeUser user, String videoID)
		 */
		int userId = 1;
		String youtubeName = "you2bectc";
		String youtubePass = "citiccitic";
		youtube.registreUser(userId, youtubeName, youtubePass);

		// getting user profile
		YouTubeUser user = youtube.getUserProfile(userId);

		String videoID = "17_SS4T-z6A";
		youtube.addFavorites(user, videoID);
	}

	@Test
	public void test_PU_116() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * getFavorites(YouTubeUser user)
		 */
		try {
			youtube.getFavorites(null);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_117() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * getFavorites(YouTubeUser user)
		 */
		int userId = 1;
		String youtubeName = "you2bectc";
		String youtubePass = "citiccitic";
		youtube.registreUser(userId, youtubeName, youtubePass);

		// getting user profile
		YouTubeUser user = youtube.getUserProfile(userId);

		String videoID = "y8w1fHfcqqE";
		YouTubeVideo video = youtube.getVideo(videoID);
		youtube.addFavorites(user, videoID);

		List<YouTubeVideoMinimal> list = youtube.getFavorites(user);
		assertNotNull(list);
		assertTrue(list.size() > 0);

		boolean found = false;
		for (int i = 0; i < list.size(); i++) {
			YouTubeVideoMinimal entry = list.get(i);
			if (entry.getTitle().equals(video.getTitle())) {
				found = true;
			}
		}
		assertTrue(found);
	}

	@Test
	public void test_PU_118() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * deleteFavorites(YouTubeUser user, String favoriteID)
		 */
		try {
			String favoriteID = "17_SS4T-z6A";
			youtube.deleteFavorites(null, favoriteID);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_119() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * deleteFavorites(YouTubeUser user, String favoriteID)
		 */
		try {

			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			youtube.deleteFavorites(user, null);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_120() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * deleteFavorites(YouTubeUser user, String favoriteID)
		 */
		try {

			int userId = 1;
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, youtubeName, youtubePass);

			// getting user profile
			YouTubeUser user = youtube.getUserProfile(userId);

			youtube.deleteFavorites(user, "");
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_121() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * deleteFavorites(YouTubeUser user, String favoriteID)
		 */

		int userId = 1;
		String youtubeName = "you2bectc";
		String youtubePass = "citiccitic";
		youtube.registreUser(userId, youtubeName, youtubePass);

		// getting user profile
		YouTubeUser user = youtube.getUserProfile(userId);

		String videoID = "y8w1fHfcqqE";
		YouTubeVideo video = youtube.getVideo(videoID);
		youtube.addFavorites(user, videoID);
		
		List<YouTubeVideoMinimal> list = youtube.getFavorites(user);
		String favoriteID = list.get(0).getVideoId();

		youtube.deleteFavorites(user, favoriteID);

		boolean notfound = true;
		list = youtube.getFavorites(user);
		for (int i = 0; i < list.size(); i++) {
			YouTubeVideoMinimal entry = list.get(i);
			if (entry.getTitle().equals(video.getTitle())) {
				notfound = false;
			}
		}
		assertTrue(notfound);
	}

	@Test
	public void test_PU_122() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * setPreferences(Integer userId, List<String> preferences)
		 */
		try {
			List<String> preferences = new ArrayList<String>();
			preferences.add("animal");
			youtube.setPreferences(null, preferences);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_123() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * setPreferences(Integer userId, List<String> preferences)
		 */
		try {
			List<String> preferences = new ArrayList<String>();
			preferences.add("animal");
			youtube.setPreferences(-1, preferences);
			fail();
		} catch (Exception e) {
		}
	}
	
	@Test
	public void test_PU_124() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * setPreferences(Integer userId, List<String> preferences)
		 */
		int userId = 1;
		String youtubeName = "you2bectc";
		String youtubePass = "citiccitic";
		youtube.registreUser(userId, youtubeName, youtubePass);

		List<String> preferences = new ArrayList<String>();
		preferences.add("animal");
		youtube.setPreferences(userId, preferences);

		UserPreferences pref = youtube.getPreferences(1);
		assertNotNull(pref);
		assertNotNull(pref.getPreferences());

		for (int i=0; i<pref.getPreferences().size();i++) {
			System.out.println(pref.getPreferences().get(i).getName());
		}		
	}

	@Test
	public void test_PU_125() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * getPreferences(Integer userId)
		 */
		try {
			youtube.getPreferences(null);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_126() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * getPreferences(Integer userId)
		 */
		try {
			youtube.getPreferences(-1);
			fail();
		} catch (Exception e) {
		}
	}
}
